package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("mobile")
@Api(tags = "移动端套餐相关接口")
@RequestMapping("/setmeal")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 查询所有套餐信息
     * @return
     */
    @PostMapping("/getSetmeal")
    @ApiOperation("查询所有套餐")
    public Result getSetmeal() {
        log.info("查询所有套餐");
        List<Setmeal> setmealList = setmealService.getSetmeal();
        Result result = new Result(true, "查询所有套餐成功", setmealList);
        return result;
    }

    @PostMapping("/findById")
    @ApiOperation("根据套餐id查询套餐")
    public Result findSetmealAndGroupById(@RequestParam Integer id) {
        log.info("根据套餐id查询套餐和检查组:{}", id);
        Setmeal setmeal = setmealService.findSetmealAndGroupById(id);
        return new Result(true,"查询套餐数据成功",setmeal);
    }

}
